﻿using UnityEngine;
using System.Collections;
namespace FSM
{
    public class CDDelayClip:FSM.Action
    {
        private Animator animator;
        private float normalzeTime;
        private int layerIndex = 0;
        private string stateName;
        private int nameHash;
        protected override void OnEnter()
        {
            if(animator == null)
            {
                animator = gameobject.GetComponent<Animator>();
            }
            if(animator != null)
            {
                nameHash = Animator.StringToHash(stateName);
            }
        }
        protected override bool OnUpdate()
        {
            var stateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex);
            if(stateInfo.IsName(stateName) && stateInfo.normalizedTime > normalzeTime)
            {
                return true;
            }
            return false;
        }
    }
}
